package com.admin.client.controller.tableConfiguration;

import com.admin.client.service.CoreMapServiceImpl;
import com.admin.client.domain.CoreMap;
import com.comment.util.message.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;

import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;



/**
 * 战斗地图(CoreMap)表服务控制层
 *
 * @author cxy
 * @since 2025-01-09 10:28:28
 */
@Api(tags = "战斗地图(CoreMap)") 
@Validated
@RestController
@RequestMapping("/coreMap")
public class CoreMapController {
    @Resource
    private CoreMapServiceImpl coreMapService;
    
    @ApiOperation(value = "全列表")
    @GetMapping(value = "/list")
    public List<CoreMap> list() {
        return coreMapService.list();
    }
    
    @ApiOperation(
            value = "导出", notes = "导出全部[战斗地图表]",
            produces = MediaType.APPLICATION_OCTET_STREAM_VALUE
    )
    @GetMapping(value = "/downloadExcel")
    public void Export(HttpServletResponse response) throws IOException {
        coreMapService.export(response);
    }

    @ApiOperation(value = "导入", notes = "覆盖更新[战斗地图表]")
    @PostMapping(value = "/importExcel")
    public ResponseResult<?> importExcel(
            @RequestPart(value = "file") MultipartFile multipartFile
    ) throws IOException {
        coreMapService.importExcel(multipartFile);
        return ResponseResult.success("导入战斗地图表成功");
    }
    
}
